<?php

class MPVehicle
{
	private $m_min_capacity;
	private $m_wheelchair_seats;
	private $m_registration;
	
	public function __construct($reg,$mincapacity)
	{
		$this->m_registration = $reg;
		$this->m_min_capacity = $mincapacity;
		$this->m_wheelchair_seats = array();
	}
	
	public function set_min_capacity($capacity)
	{
		$this->m_min_capacity = $capacity;
	}
	
	public function add_wheelchair_seat($replace_capacity)
	{
		$this->m_wheelchair_seats[] = $replace_capacity;
	}
	
	public function get_max_capacity()
	{
		$totalSeats = $this->m_min_capacity;
		foreach( $this->m_wheelchair_seats as $seats ) $totalSeats += $seats;
		return $totalSeats;
	}
	
	public function get_min_capacity()
	{
		return $this->m_min_capacity;
	}
	
	public function get_wheelchair_capacity()
	{
		return count( $this->m_wheelchair_seats );
	}
	
	public function get_registration()
	{
		return $this->m_registration;
	}
}

class MPVehicles
{
	private $m_vehicles;
	private $m_company_id;
	
	public function __construct($companyID)
	{
		$this->m_vehicles = array();
		$this->m_company_id = $companyID;
	}
	
	public function load_from_db($db)
	{
		$vehicles = $db->getVehicles($this->m_company_id);
		
		foreach( $vehicles as $v )
		{
			$vehicleTemp = new MPVehicle($v['registration'],$v['capacity']);
			for( $wc=$v['wheelchair_capacity']; $wc>0; --$wc )
				$vehicleTemp->add_wheelchair_seat(2);
			$this->m_vehicles[] = $vehicleTemp;
		}
	}
	
	public function add_vehicle($vehicle)
	{
		$this->m_vehicles[] = $vehicle;
	}
	
	public function get_vehicles()
	{
		return $this->m_vehicles;
	}
}

?>